import 'package:base_flutter/base_flutter.dart';
import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:ls_work/a_elder/models/elder_entity.dart';
import 'package:ls_work/a_elder/page/elder_info_page.dart';
import 'package:ls_work/res/resources.dart';
import 'package:ls_work/ui/elder_detail_info_page.dart';
import 'package:ls_work/util/app_navigator.dart';

class ElderCell extends StatelessWidget {
  final bool isSelected; //健康登记选择老者
  final ElderInfo info;
  final Function(ElderInfo elderInfo)? cellClickBlock;
  ElderCell({Key? key, required this.info, this.isSelected = false, this.cellClickBlock});
  @override
  Widget build(BuildContext context) {
    String sexName = info.sexName ??'';
    String age = info.age != null ? info.age.toString() : '';
    // String branchName = info.branchName != null ? info.branchName : '';
    String buildingNo = info.buildingNo ?? '';
    String floorNo = info.floorNo ?? '';
    String roomNo = info.roomNo ?? '';
    String nurseLevelName =
        info.nurseLevelName ?? '';
    String statusSecondName =
        info.statusSecondName ?? '';
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        if (cellClickBlock != null) {
          cellClickBlock!(info);
        } else if (isSelected) {
          // AppNavigator.push(
          //   context,
          //   ElderInfoPage(
          //     customerId: info.id!,
          //   ),
          // );
          Go().push(ElderDetailInfoPage(customerId: info.id!));
        }
      },
      child: Container(
        width: double.infinity,
        padding: EdgeInsets.fromLTRB(12, 15, 5, 0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    // CircleAvatar(
                    //   backgroundColor: Colours.bg_gray,
                    //   radius: 20,
                    //   backgroundImage: NetworkImage(iconUrl),
                    // ),
                    SizedBox(
                      width: 45,
                      height: 45,
                      child: CircleAvatar(
                        backgroundColor: Colors.brown,
                        child: Text('${info.name?.substring(0, 1)}'),
                      ),
                    ),
                    // LoadAssetImage('default/d_mrtx'),
                    SizedBox(
                      height: 5,
                    ),
                  ],
                ),
                SizedBox(
                  width: 13,
                ),
                Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Container(
                      width: ScreenUtil.getScreenW(context) - 75,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          Text(
                            info.name??"",
                            style: TextStyles.textBoldDark16,
                          ),
                          Text(
                            '', //38.5℃
                            style: TextStyles.textGray12,
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 5,
                    ),
                    Container(
                      width: ScreenUtil.getScreenW(context) - 75,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          Text(
                            //$branchName#
                            '$sexName  $age $buildingNo#$floorNo-$roomNo  护理$nurseLevelName',
                            style: TextStyles.textGray14,
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 5,
                    ),
                    Chip(
                      label: Text('$statusSecondName',
                          style: TextStyle(color: Colors.orange)),
                      backgroundColor: Colors.orange[100],
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(2.0),
                      ),
                    ),
                  ],
                ).setWeight(1),
              ],
            ),
            SizedBox(
              height: 15,
            ),
            Container(
              height: 1,
              color: Colours.bg_gray,
              width: double.infinity,
            )
          ],
        ),
      ),
    );
  }
}
